{% macro pr_table(wb, id, searchBarId) %}
<div class="searchbar-table">
  <input type="text" id="{{ searchBarId }}" onkeyup="searchTable('{{ id }}', '{{ searchBarId }}')" placeholder="Search terms..."/>
  <table id="{{ id }}" class="data-table">
  <thead>
    <tr>
      <th rowspan="2">PR</th>
      <th rowspan="2">Build State</th>
      <th colspan="{{ wb.gh_status_names | length }}">GitHub Statuses</th>
      <th rowspan="2">Labels</th>
      <th rowspan="2">Branch</th>
      <th rowspan="2">Review State</th>
      <th rowspan="2">Author</th>
    </tr>
    <tr>
      {% for name in wb.gh_status_names %}
      <th>{{ name }}</th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
    {% for pr in wb.prs %}
    <tr>
      <td>
        <a rel="noopener" href="https://github.com/{{ wb.repo }}/pull/{{ pr.number }}">
          {{ pr.title }} <span class="gh-number">#{{ pr.number }}</span>
        </a>
      </td>
      <td>
        {% if pr.build_state is not none %}
          <a rel="noopener" href="{{ base_path }}/watched_branches/{{ wb.index }}/pr/{{ pr.number }}">{{ pr.build_state }}</a>
        {% else %}
          pending
        {% endif %}
        {% if pr.build_state is not none and pr.out_of_date %}
          *
        {% endif %}
      </td>
      {% for name in wb.gh_status_names %}
      <td>{{ pr['gh_statuses'][name] | default("") }}</td>
      {% endfor %}
      <td>
        {{ pr.labels|join(", ") }}
      </td>
      <td>
        {{ pr.source_branch_name }}
      </td>
      <td>
        {% if pr.review_state %}
        {{ pr.review_state }}
        {% endif %}
      </td>
      <td>
        {{ pr.author }}
      </td>
    </tr>
    {% endfor %}
  </tbody>
  </table>
</div>
{% endmacro %}
